<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
function createPerson(name, age, sex){
    var obj = {};
    obj.name = name;
    obj.age = age;
    obj.sex = sex;
    return obj;
}
/*function createPerson(name, age, sex){
    var obj = new Object();   // new Object()  相当于 {}
    obj.name = name;
    obj.age = age;
    obj.sex = sex;
    return obj;
}*/

/*function createPerson(name, age, sex){
    return {
        name: name,
        age: age,
        sex: sex
    }
}*/

//了解
function createPerson(name, age, sex){
    return {name, age, sex}
}

var p1 = createPerson("李四", 20, "男")
var p2 = createPerson("李四1", 202, "男1")
console.log(p1);
console.log(p2);
</script>
</body>
</html>
<!--
第一种获取对象的方式:  字面量

第二种:
    工厂模式(工厂方法)

-->